#include <queue>

class Solution
{
public:
    int findKthLargest(vector<int> &nums, int k)
    {
        priority_queue<int, vector<int>, greater<int>> maxs;
        for (auto num : nums)
        {
            if (maxs.size() < k)
            {
                maxs.push(num);
            }
            else if (num >= maxs.top())
            {
                maxs.pop();
                maxs.push(num);
            }
        }
        return maxs.top();
    }
};